package com.wuliang.blog.core.jpa;

import com.wuliang.blog.core.basic.BasicEntity;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;

public interface EntityFieldTypeAdapter<T> {

    /**
     * 转为 谓言
     * @see Predicate
     *
     * @param entity          对哪个实体类操作
     * @param criteriaBuilder 用来构建 CriteriaQuery 的构建器对象
     * @param fieldName       属性名称
     * @param fieldValue      属性值
     * @param from            字段对象
     * @return {@linkplain Predicate}
     */
    @SuppressWarnings("unchecked")
    public Predicate toPredicate(Class<? extends BasicEntity> entity, CriteriaBuilder criteriaBuilder, String fieldName,
                                 T fieldValue, From<Object, T> from);

}
